<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            /* 定视口 */
            width: 41px;
            height: 37px;
            /* 插图 */
            background-image: url('./seat.jpg');
            background-position: -41px 0;
        }

        .active {
            width: 41px;
            height: 37px;
            background-image: url('./seat.jpg');
            background-position: 0 0;
        }

        section {
            display: flex;
        }
    </style>
</head>

<body>
    <section>
        <div class="active"></div>
        <div></div>
        <div></div>
        <div class="active"></div>
        <div></div>
        <div></div>
    </section>


    <script>

        let divs = document.getElementsByTagName('div');

        for (let i = 0; i < divs.length; i++) {
            divs[i].onclick = function () {
                divs[i].classList.toggle('active')
            }

        }



    </script>
</body>

</html>